<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <base target="_self">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache,must-ridate">
    <meta http-equiv="expires" content="0">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/static/plugins/bootstrap/css/bootstrap.min.css" />
</head>

<style  type="text/css">
    .required {
        color: red;
    }       
</style>

<body>
    <div style="height: 20px; text-align: right;">
        <button type="button" onclick="javascript:onSave();" class="btn blue">保 存</button>&nbsp;&nbsp;
    </div>

    <ul id="myTab" class="nav nav-tabs">
        <li class="active">
            <a href="#productInfo" data-toggle="tab">
               产品信息要素
            </a>
        </li>
    </ul>

    <div id="myTabContent" class="tab-content">
        <div class="tab-pane fade in active" id="productInfo">
            <div style="height:620px;overflow-y:auto">
                <table border="1" bordercolor="#C0C0C0" cellspacing="0" cellpadding="2" style="width: 100%;">
				<tr> <td colspan=3><b>下面所有数据都以信托项目清算报告披露数据为准:</b><td></tr>
                    <tr id="trtrust">
                        <td style="width: 20%;">
                            <span class="required">*</span>办理日期:
                        </td>
                        <td style="width: 30%;">
                            <input type="date" id="handledate" name="handledate" style="width: 320px;">
                        </td>
                        <td style="width: 20%;">
                            <span class="required">*</span>终止登记反馈日期:
                        </td>
                        <td style="width: 30%;">
                            <input type="date" id="overdate" name="overdate" style="width: 320px;">
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 20%;">
                            <span class="required">*</span>信托登记系统产品编码 :
                        </td>
                        <td style="width: 30%;">
                            <input type="text" id="djcpbh" name="djcpbh" style="width: 280px;">
                        </td>					
                        <td style="width: 20%;">
                            <span class="required">*</span>信托产品名称:
                        </td>
                        <td style="width: 30%;">
                            <input type="text" id="cpqc" name="cpqc" style="width: 280px;">
                        </td>
					</tr>
                    <tr>
                        <td>
                            <span class="required">*</span>清算日期 :
							<br>提示【填写清算报告落款日期】
                        </td>
                        <td>
                            <input type="date" id="qsrq" name="qsrq" style="width: 280px;">
                        </td>					
                        <td>
                            <span class="required">*</span>是否按约定日期清算:
                        </td>
                        <td>
                            <input type="radio" name="sfaydrqqs" value="0" onchange="javascript:changeInfo('1')"/>提前
                            <input type="radio" name="sfaydrqqs" value="1" onchange="javascript:changeInfo('1')"/>正常
							<input type="radio" name="sfaydrqqs" value="2" onchange="javascript:changeInfo('1')"/>推迟
                        </td>
                    <tr>
                        <td>
                            <span class="required">*</span>成立日
                        </td>
                        <td>
                            <input type="text" id="startdate" name="startdate" style="width: 280px;" readonly>
                        </td>					
                        <td>
                            <span class="required">*</span>到期日:
                        </td>
                        <td>
                            <input type="text" id="finishdate" name="finishdate" style="width: 280px;" readonly>
                        </td>					
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>实收信托金额:
                        </td>
                        <td>
                            <input type="number" id="ssxtje" name="ssxtje" style="width: 280px;">(元)
                        </td>
                        <td>
                            <span class="required">*</span>信托本金累计给付额:
                        </td>
                        <td>
                            <input type="number" id="xtbjljgfe" name="xtbjljgfe" style="width: 280px;">(元)
                        </td>						
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>信托收益累计分配额:
                        </td>
                        <td>
                            <input type="number" id="xtsyljfpe" name="xtsyljfpe" style="width: 280px;">(元)
                        </td>					
                        <td>
                            <span class="required">*</span>加权信托规模:
                        </td>
                        <td>
                            <input type="number" id="jqpjxtgm" name="jqpjxtgm" style="width: 280px;" readonly>(元)
                        </td>					
                    </tr>
                    <tr>
                        <td>
                            投资顾问等累计固定报酬:
                        </td>
                        <td>
                            <input type="number" id="tgljgdbc" name="tgljgdbc" style="width: 280px;">(元)
                        </td>
                        <td>
                            投资顾问等累计业绩报酬:
                        </td>
                        <td>
                            <input type="number" id="tgljyjbc" name="tgljyjbc" style="width: 280px;">(元)
                        </td>					
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>受托人累计固定报酬:
                        </td>
                        <td>
                            <input type="number" id="strljgdbc" name="strljgdbc" style="width: 280px;" onchange="javascript:changeInfo('2')">(元)
                        </td>						
                        <td>
                            <span class="required">*</span>实际信托报酬率:
                        </td>
                        <td>
                            <input type="number" id="sjxtbcl" name="sjxtbcl" style="width: 280px;" readonly>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>受托人累计业绩报酬:
                        </td>
                        <td>
                            <input type="number" id="strljyjbc" name="strljyjbc" style="width: 280px;" onchange="javascript:changeInfo('2')">(元)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>信托费用总额:
                        </td>
                        <td>
                            <input type="number" id="xtfyze" name="xtfyze" style="width: 280px;" onchange="javascript:changeInfo('3')">(元)
                        </td>
                        <td>
                            <span class="required">*</span>信托费用率:
                        </td>
                        <td>
                            <input type="number" id="xtfyl" name="xtfyl" style="width: 280px;" readonly>
                        </td>						
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>信托保管费:
                        </td>
                        <td>
                            <input type="number" id="xtbgf" name="xtbgf" style="width: 280px;" onchange="javascript:changeInfo('4')">(元)
                        </td>
                        <td>
                            <span class="required">*</span>信托保管费率:
                        </td>
                        <td>
                            <input type="number" id="xtbgfl" name="xtbgfl" style="width: 280px;" readonly>
                        </td>					
                    </tr>
                    <tr>
                        <td>
                            <span class="required">*</span>实际收益:
                        </td>
                        <td>
                            <input type="number" id="sjsy" name="sjsy" style="width: 280px;" onchange="javascript:changeInfo('5')">(元)
                        </td>
                        <td>
							<span class="required">*</span>实际收益率:
                        </td>
                        <td>
                            <input type="number" id="sjsyl" name="sjsyl" style="width: 280px;" readonly>
                        </td>
                    </tr>
                    <tr>						
                        <td>
                            损失金额:
                        </td>
                        <td>
                            <input type="number" id="sshje" name="sshje" style="width: 280px;">(元)
                        </td>						
                        <td>
                            涉诉金额:
                        </td>
                        <td>
                            <input type="number" id="shsje" name="shsje" style="width: 280px;">(元)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            赔付金额:
                        </td>
                        <td>
                            <input type="number" id="pfje" name="pfje" style="width: 280px;">(元)
                        </td>						
                    </tr>					
					<tr>
                        <td>
                            业务信息说明:
                        </td>
                        <td colspan="3">
							<textarea cols="200" rows="3" id="ywxxsm" name="ywxxsm" style="width:400px;"></textarea>
                        </td>
                    </tr>
					<tr><input type="hidden" id="workdate" name="workdate" style="width: 320px;"></tr>
					<tr><input type="hidden" id="startdate" name="startdate" style="width: 320px;"></tr>
					<tr><input type="hidden" id="enddate" name="enddate" style="width: 320px;"></tr>
					<tr><input type="hidden" id="workday" name="workday" style="width: 320px;"></tr>
                </table>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="/static/plugins/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="/static/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript">

        //初始化数据
        let ydjData = new Object();
        $(function () {
            //获取流程参数
            let flowid = GetQueryValue('flowid');
            let itemid = GetQueryValue('itemid');
			let taskid = GetQueryValue('taskid');
			let nextnode = GetQueryValue('nextnode');
			if(nextnode=="X644307B0B24442290B4A6BAED269009"){
				jQuery("#trtrust").show();
			}else{
				jQuery("#trtrust").hide();
			}
            if (taskid == null) {
                itemid = "1@@"+itemid;
            } else {
                itemid = "2@@"+taskid;
            }
            find_app_dfs_zxd_zzcpxx_by_regitem_id(flowid, itemid);
        });

        //查询预登记-产品信息要素
        function find_app_dfs_zxd_zzcpxx_by_regitem_id(flowid, itemid) {
            //根据项目ID采集现有信息
            jQuery.ajax({
                data: { "flowid": flowid, "itemid": itemid },
                url: "/node/find_app_dfs_zxd_zzcpxx_by_regitem_id/" + itemid,
                async: false,
                cache: false,
                success: function (data) {
                    ydjData = data;
					$("#handledate").val(data.handledate);
					$("#overdate").val(data.overdate);
                    $("#djcpbh").val(data.djcpbh);
                    $("#cpqc").val(data.cpqc);
					$("input[name='sfaydrqqs'][value='"+data.sfaydrqqs+"']").attr("checked", true);
					$("#qsrq").val(data.qsrq);
					$("#ssxtje").val(data.ssxtje);
					$("#xtbjljgfe").val(data.xtbjljgfe);
					$("#xtsyljfpe").val(data.xtsyljfpe);
					$("#tgljgdbc").val(data.tgljgdbc);
					$("#tgljyjbc").val(data.tgljyjbc);
					$("#strljgdbc").val(data.strljgdbc);
					$("#strljyjbc").val(data.strljyjbc);
					$("#sjxtbcl").val(data.sjxtbcl);
					$("#xtfyze").val(data.xtfyze);
					$("#xtfyl").val(data.xtfyl);
					$("#xtbgfl").val(data.xtbgfl);
					$("#sjsy").val(data.sjsy);
					$("#sjsyl").val(data.sjsyl);
					$("#sshje").val(data.sshje);
					$("#shsje").val(data.shsje);
					$("#pfje").val(data.pfje);
					$("#workdate").val(data.workdate);
					$("#jqpjxtgm").val(data.jqpjxtgm);
					$("#startdate").val(data.startdate);
					$("#enddate").val(data.enddate);
					$("#finishdate").val(data.finishdate);
					$("#workday").val(data.workday);
					$("#xtbgf").val(data.xtbgf);
					$("#ywxxsm").val(data.ywxxsm);
                }
            });
        }
		
		//设置text,textarea和select对应值
		function setFormValue(name,value){
			$('#'+name).val(value);
		}
		
		//设置Radio对应值
		function setRadioValue(name,value){
			if(value==""){
				$("input[name="+name+"]").prop("checked",false);
			}else{
				$("input[name="+name+"][value="+value+"]").attr("checked", true);
			}
		}
		
		//设置Box对应值
		function setBoxValue(name,content){	
			if(content.indexOf('No,')>=0)
			{
				content=content.replace('No,','');
				let returnValue = content.split(",");
				$.each(returnValue, function (index, value) {
					$("#"+name+value).attr("checked",false)
				});
			}else{
				let returnValue = content.split(",");
				$.each(returnValue, function (index, value) {
					$("#"+name+value).attr("checked",true)
				});			
			}
		}
		
		//获取text,textarea和select对应值
		function getFormValue(name){
			let value = $('#'+name).val();
			return value;
		}
		
		//获取Radio对应值
		function getRadioValue(name){
			let value = $("input[name="+name+"]:checked").val();
			return value;
		}
		
		//获取Box对应值
		function getBoxValue(name){
			let value = $("input:checkbox[name="+name+"]:checked");
            let chvalue = [];
            $.each(value, function () {
                chvalue.push($(this).val());
            });
            value = chvalue.join(",");
			return value;
		}
		
		//日期格式化处理
		Date.prototype.Format = function(fmt)  
		{ 
			var o = {  
				"M+" : this.getMonth()+1,         //月份  
				"d+" : this.getDate(),          //日  
				"h+" : this.getHours(),          //小时  
				"m+" : this.getMinutes(),         //分  
				"s+" : this.getSeconds(),         //秒  
				"q+" : Math.floor((this.getMonth()+3)/3), //季度  
				"S" : this.getMilliseconds()       //毫秒  
			};  
			if(/(y+)/.test(fmt))  
				fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));  
			for(var k in o)  
				if(new RegExp("("+ k +")").test(fmt))  
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));  
			return fmt;  
		}

        //字段必输项+内容大小限制校验
		function checkInfo(name,content,flag,type){
			if(type=='text') value = getFormValue(name);
			else if(type=='box') value = getBoxValue(name);
			else if(type=='radio') value = getRadioValue(name);
			else value = getFormValue(name);
			if(flag=="required")
			{
				if(typeof(value)=="undefined" || value==null || value.length==0  || value.length==''){
					alert("字段["+content+"]为必填项!");
					document.getElementById(name).focus();
					return false;
				}
			}else if(flag=="length"){
				if(!(typeof(value)=="undefined" || value==null || value.length==0  || value.length=='') && value.length>type){
					alert("字段["+content+"]内容超过最大限制!");
					document.getElementById(name).focus();
					return false;
				}			
			}else if(flag=="number"){
				if(!(typeof(value)=="undefined" || value==null || value.length==0  || value.length=='')){
					var typeValue=type.split(",");
					if(value.indexOf(".")<0) value=value+'.00';
					var contentValue=value.split(".");
					if(contentValue[0].length > (typeValue[0]-typeValue[1]) || contentValue[1].length > typeValue[1]){
						alert("字段["+content+"]内容超过最大限制!");
						document.getElementById(name).focus();
						return false;
					}					
				}			
			}
			return true;
		}		
		//保存之前必输项校验
		function logicCheck(){
			let nextnode = GetQueryValue('nextnode');
			if(nextnode=="X644307B0B24442290B4A6BAED269009")
			{
				//if(!checkInfo('handledate','办理日期','required','text')) return false;
				//if(!checkInfo('overdate','终止登记反馈日期','required','text')) return false;
			}
			if(!checkInfo('djcpbh','信托登记系统产品编码','required','text')) return false;
			if(!checkInfo('cpqc','信托产品名称','required','text')) return false;
			if(!checkInfo('sfaydrqqs','是否按约定日期清算','required','radio')) return false;
			if(!checkInfo('qsrq','清算日期','required','text')) return false;
			if(!checkInfo('ssxtje','实收信托金额','required','text')) return false;
			if(!checkInfo('xtbjljgfe','信托本金累计给付额','required','text')) return false;
			if(!checkInfo('xtsyljfpe','信托收益累计分配额','required','text')) return false;
			if(!checkInfo('strljgdbc','受托人累计固定报酬','required','text')) return false;
			if(!checkInfo('strljyjbc','受托人累计业绩报酬','required','text')) return false;
			if(!checkInfo('sjxtbcl','实际信托报酬率','required','text')) return false;
			if(!checkInfo('xtfyze','信托费用总额','required','text')) return false;
			if(!checkInfo('xtfyl','信托费用率','required','text')) return false;
			if(!checkInfo('xtbgfl','信托保管费率','required','text')) return false;
			if(!checkInfo('sjsy','实际收益','required','text')) return false;
			if(!checkInfo('sjsyl','实际收益率','required','text')) return false;
			if(!checkInfo('jqpjxtgm','加权平均信托规模','required','text')) return false;
			if(!checkInfo('xtbgf','信托保管费','required','text')) return false;
			//监管报送内容大小限制校验
			if(!checkInfo('djcpbh','信托登记系统产品编码','length','50')) return false;
			if(!checkInfo('cpqc','信托产品名称','length','50')) return false;
			if(!checkInfo('qsrq','清算日期','length','50')) return false;
			if(!checkInfo('ssxtje','实收信托金额','number','16,2')) return false;
			if(!checkInfo('xtbjljgfe','信托本金累计给付额','number','16,2')) return false;
			if(!checkInfo('xtsyljfpe','信托收益累计分配额','number','16,2')) return false;
			if(!checkInfo('strljgdbc','受托人累计固定报酬','number','16,2')) return false;
			if(!checkInfo('strljyjbc','受托人累计业绩报酬','number','16,2')) return false;
			if(!checkInfo('sjxtbcl','实际信托报酬率','number','8,6')) return false;
			if(!checkInfo('xtfyze','信托费用总额','number','16,2')) return false;
			if(!checkInfo('xtfyl','信托费用率','number','8,6')) return false;
			if(!checkInfo('xtbgfl','信托保管费率','number','8,6')) return false;
			if(!checkInfo('xtbgf','信托保管费','number','16,2')) return false;
			if(!checkInfo('sjsy','实际收益','number','16,2')) return false;
			if(!checkInfo('sjsyl','实际收益率','number','8,6')) return false;
			if(!checkInfo('tgljgdbc','投资顾问等累计固定报酬','number','16,2')) return false;
			if(!checkInfo('tgljyjbc','投资顾问等累计业绩报酬','number','16,2')) return false;
			if(!checkInfo('sshje','损失金额','number','16,2')) return false;
			if(!checkInfo('shsje','涉诉金额','number','16,2')) return false;
			if(!checkInfo('pfje','赔付金额','number','16,2')) return false;
			if(!checkInfo('jqpjxtgm','加权平均信托规模','number','16,2')) return false;
			if(!checkInfo('ywxxsm','业务信息说明','length','1000')) return false;
					
			var workdate=getFormValue('workdate');
			var qsrq=getFormValue('qsrq');
			if(workdate > qsrq){
				alert("已超期办理，应当在清算报告出具日/落款日10个工作日内办理!");
			}
			return true;
		}
        
        //产品终止登记信息保存
        function onSave() {
			//保存校验
			if(!logicCheck()){
				return false;	
			}		
            //产品信息要素
			ydjData.handledate = $("#handledate").val();
			ydjData.overdate = $("#overdate").val();
            ydjData.sfaydrqqs = $("input[name='sfaydrqqs']:checked").val();
            ydjData.djcpbh=$("#djcpbh").val();
            ydjData.cpqc=$("#cpqc").val();
            ydjData.qsrq=$("#qsrq").val();
			ydjData.ssxtje=$("#ssxtje").val();
			ydjData.xtbjljgfe=$("#xtbjljgfe").val();
			ydjData.xtsyljfpe=$("#xtsyljfpe").val();
			ydjData.tgljgdbc=$("#tgljgdbc").val();
			ydjData.tgljyjbc=$("#tgljyjbc").val();
			ydjData.strljgdbc=$("#strljgdbc").val();
			ydjData.strljyjbc=$("#strljyjbc").val();
			ydjData.sjxtbcl=$("#sjxtbcl").val();
			ydjData.xtfyze=$("#xtfyze").val();
			ydjData.xtfyl=$("#xtfyl").val();
			ydjData.xtbgfl=$("#xtbgfl").val();
			ydjData.sjsy=$("#sjsy").val();
			ydjData.sjsyl=$("#sjsyl").val();
			ydjData.sshje=$("#sshje").val();
			ydjData.shsje=$("#shsje").val();
			ydjData.pfje=$("#pfje").val();
			ydjData.jqpjxtgm=$("#jqpjxtgm").val();
			ydjData.xtbgf=$("#xtbgf").val();
			ydjData.ywxxsm=$("#ywxxsm").val();
            jQuery.ajax({
                //请求方式
                type: "POST",
                //请求地址
                url: "/node/insert_app_dfs_zxd_zzcpxx",
                //数据，json对象
                data: ydjData,
                //请求成功
                success: function (data) {
                    alert("保存成功！");
                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    alert("保存失败！");
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });
        }

        //获取GET参数
        function GetQueryValue(queryName) {
            var query = decodeURI(window.location.search.substring(1));
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == queryName) { return pair[1]; }
            }
            return null;
        }
		//预登记填报说明
        function inputContent(){
			window.open('/node/tianbao.html?type=3','_blank','');
		}
        //选择发生值变化
        function changeInfo(no) {
            if(no=="1"){
				var enddate=getFormValue('enddate');
				var sfaydrqqs=getRadioValue('sfaydrqqs');
				if(sfaydrqqs=="0" || sfaydrqqs=="1")
				{
					alert("提示本产品信托登记时计划到期日为["+enddate+"]，如产品展期请先办理变更登记!");
				}
			}else if(no=="2"){
				var strljgdbc=getFormValue('strljgdbc');
				var strljyjbc=getFormValue('strljyjbc');
				var jqpjxtgm=getFormValue('jqpjxtgm');
				var workday=getFormValue('workday');
				
				if(parseInt(workday)>0){
					var value=(parseFloat(strljgdbc)+parseFloat(strljyjbc))/parseFloat(jqpjxtgm)*365/parseInt(workday);
					setFormValue('sjxtbcl',value.toFixed(6));
				}else {
					setFormValue('sjxtbcl','0');
				}
			}else if(no=="3"){
				var xtfyze=getFormValue('xtfyze');
				var jqpjxtgm=getFormValue('jqpjxtgm');
				var workday=getFormValue('workday');
				
				if(parseInt(workday)>0){
					var value=(parseFloat(xtfyze))/parseFloat(jqpjxtgm)*365/parseInt(workday);
					setFormValue('xtfyl',value.toFixed(6));
				}else {
					setFormValue('xtfyl','0');
				}
			}else if(no=="4"){
				var xtbgf=getFormValue('xtbgf');
				var jqpjxtgm=getFormValue('jqpjxtgm');
				var workday=getFormValue('workday');
				
				if(parseInt(workday)>0){
					var value=(parseFloat(xtbgf))/parseFloat(jqpjxtgm)*365/parseInt(workday);
					setFormValue('xtbgfl',value.toFixed(6));
				}else {
					setFormValue('xtbgfl','0');
				}
			}else if(no=="5"){
				var sjsy=getFormValue('sjsy');
				var jqpjxtgm=getFormValue('jqpjxtgm');
				var workday=getFormValue('workday');
				if(parseInt(workday)>0){
					var value=(parseFloat(sjsy))/parseFloat(jqpjxtgm)*365/parseInt(workday);
					setFormValue('sjsyl',value.toFixed(6));
				}else {
					setFormValue('sjsyl','0');
				}
			}
		}				
    </script>
</body>

</html>